/*
*
==============================================================================
*  Name        : 
*  Part of     : Omen Game Engine
*  Description : 
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#pragma once

#include "OmenConfig.h"
#include "IOmenObject.h"

#include <vector>
#include <string>

namespace Omen {

    /// All supported asset types
    typedef enum {
            Asset_TypeUnkown,
            Asset_3dModel,
            Asset_TextureMap,
            Asset_Audio,
            Asset_Script,
            Asset_Animation,
            Asset_Movie
        } AssetType;

    class IAssetNode;

    /// Basic Asset object interface
    class OMEN_API IAsset {
    public:
        virtual IAssetNode* treeNode() = 0;

        virtual std::wstring name() const = 0;
        
        virtual bool loadAsset() = 0;               /// Loads the asset and return true if succeeded, false otherwise
        virtual bool releaseAsset() = 0;            /// Releases the allocated resources by this asset

        virtual void setType( Omen::AssetType type ) = 0;  // Sets the asset type to given type
        virtual Omen::AssetType& type() = 0;               // Returns a reference to the asset type

        virtual std::wstring& path() = 0;            /// Returns the path of the asset
        virtual std::wstring& filename() = 0;        /// Returns the filename of the asset
    };

    /// Interface object for Asset node in tree
    class OMEN_API IAssetNode {
    public:
        virtual std::wstring name() const = 0;
        virtual void addChild( IAssetNode* pChild ) = 0;
        virtual IAssetNode* parent() const = 0;
        virtual unsigned long getChildren( IAssetNode** children, unsigned long& maxNum ) = 0;
        virtual IAssetNode* findChild( const std::wstring& nodeName ) const = 0;
        virtual unsigned long childCount() const = 0;
        virtual IAsset* asset() = 0;
        virtual void setAsset( IAsset* pAsset ) = 0;
    };

    /// Asset Manager Interface class to access the assets
    class OMEN_API IAssetManager : public Omen::IObject {
    public: 
        /// Enumerate assets with given type in given directory and adds them to the asset manager
        virtual unsigned long enumerateAssets( const Omen::AssetType& type, const std::wstring& assetPath, bool recursive ) = 0;

        /// Get anumerated assets of given type
        virtual void getAssets( const Omen::AssetType& type, std::vector<IAssetNode>& assets ) = 0;

        /// Get the root node of all assets
        virtual void getAssets( IAssetNode& rootNode ) = 0;
        
        /// Find an asset with given type and name that exactly or partially matches the given name
        virtual bool findAssets( const Omen::AssetType& type, const std::wstring& name, std::vector<IAssetNode*>& assets ) = 0;
    };

    // ----------------------------------------------------------------------- //

} // namespace Omen

/// EOF